package com.woniu.product.controller;

import com.woniu.common.dto.CouponStatusDTO;
import com.woniu.common.utils.ResponseData;
import com.woniu.product.pojo.Coupon;
import com.woniu.product.pojo.CouponStatus;
import com.woniu.product.service.CouponService;
import com.woniu.product.service.CouponStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ltyipx
 * @version 1.0
 * @description:TODO
 * @date 2024/8/10 15:39
 */
@RestController
public class CouponController {
    @Autowired
    private CouponService couponService;
    @Autowired
    private CouponStatusService couponStatusService;

    @PostMapping("/queryMyCoupons")
    public ResponseData<?> queryMyCoupons(@RequestBody String[] productIds){
        return couponService.queryMyCoupons(productIds);
    }

    @GetMapping("/queryCouponById")
    public ResponseData<?> queryCouponById(@RequestParam("id") String id){
        return couponStatusService.queryCouponById(id);

    }


    @GetMapping("/UseCoupon")
    void UseCoupon(@RequestParam("couponId") String couponId){
        couponStatusService.lambdaUpdate().setSql("status = 1").eq(CouponStatus::getId,couponId).update();
    }
}
